module.exports = (function(){
	var private = {};
	private.callAction = function(controller, action, req, res) {
		console.log(Date() +', connect by: ' + req.ip+', '+req.method+': '+ req.originalUrl);
		var Action = require(GLOBAL.basePath+'/controllers/'+controller+'/'+ action +'.js');
		var actionObj = new Action();
		actionObj.init(req, res);
	}
	
	App.all('/:controller/:action', function(req, res){
		var controller = req.param('controller');
		var action = req.param('action');
		private.callAction(controller, action, req, res);
	});
	
	App.all('/:controller', function(req, res){
		var controller = req.param('controller');
		var action = 'index';
		private.callAction(controller, action, req, res);
	});
	
	App.listen(3001);
	console.log('Listening on port 3001');
	
	return true;
}());